<template>
  <div>
    <a-form laba-width="80px" :model="formData">
      <a-form-item label="文案">
        <a-input v-model="formData.text"></a-input>
      </a-form-item>
      <a-form-item label="名称">
        <a-input v-model="formData.name"></a-input>
      </a-form-item>
      <a-form-item label="活动区域">
        <a-input v-model="formData.region"></a-input>
      </a-form-item>
      <a-form-item label="活动形式">
        <a-input v-model="formData.type"></a-input>
      </a-form-item>
      <a-form-item label="A">
        <a-input v-model="formData.a.a1"></a-input>
        <a-input v-model="formData.a.a2"></a-input>
      </a-form-item>
      <a-form-item>
        <a-button type="primary" @click="onSubmit">保存</a-button>
      </a-form-item>
    </a-form>
  </div>
</template>
<script>
export default {
  name: "",
  props: {
    nodeData: Object,
    lf: Object || String,
  },
  mounted() {
    const { properties, text } = this.$props.nodeData;
    if (properties) {
      this.$data.formData = Object.assign({}, this.$data.formData, properties);
    }
    if (text && text.value) {
      this.$data.formData.text = text.value;
    }
    if (text && text.value) {
      this.$data.text = text.value;
    }
  },
  data() {
    return {
      text: "",
      formData: {
        text: "",
        name: "",
        region: "",
        type: "",
        a: {
          a1: "",
          a2: "",
        },
      },
    };
  },
  methods: {
    onSubmit() {
      const { id } = this.$props.nodeData;
      this.$props.lf.setProperties(id, this.$data.formData);
      this.$props.lf.updateText(id, this.$data.formData.text);
      this.$emit("onClose");
    },
  },
};
</script>
<style scoped>
</style>
